$(document).ready(function(){
	
	  $(".header").load("header.html"); 
	  $(".footer").load("footer.html");
	
});
var myModule = angular.module('myModule', []);




myModule.controller('MyController', function ($scope,$http,$location) {

    $scope.contest_regItems=[];
    $scope.teamItems=[];
    $scope.userItems=[];
    $scope.selectedIndex=null;
    
    
    $scope.loadData = function() {
    	myUtil.onHttp($http,'get','contest_reg_applyDate.do',{id : $scope.contest_reg_id},null,
    			function(data){
    				$scope.contest_regItems=data.contest_reg;
    				$scope.teamItems=data.team;
    			}
    	)
    }
    
    $scope.borderbottom ={};    
    $scope.loadUser=function(index,id){
    	if($scope.selectedIndex==index){
    		$scope.selectedIndex=null;
   
    	}
    	else{
    		$scope.selectedIndex=index;
    		myUtil.onHttp($http,'get','userList.do',{team_id:id},null,
    				function(data){
    			$scope.userItems=data;
    			$scope.borderbottom ={'border-style': 'solid','border-left-style': 'none'}; 
    		})
    	}
    }
    $scope.access=function(index){
    	var id = $scope.teamItems[index].team_id;
    	if(confirm("정말 "+$scope.teamItems[index].team_name+"팀을 대회에 참여시키겠습니까?")){
    		myUtil.onHttp($http,'post','accessYes.do',null,$scope.teamItems[index],
    				function(data){
    					$scope.teamItems.splice(index,1);
    		})
    	}
    }
    
    $scope.accessNo=function(index){
    	var id = $scope.teamItems[index].team_id;
    	if(confirm("정말 "+$scope.teamItems[index].team_name+"팀을 거절하시겠습니까?")){
    		myUtil.onHttp($http,'get','accessNo.do',{team_id:id},null,
    				function(data){
    			 		$scope.teamItems.splice(index,1);
    		})
    	}
    }
    
    $scope.proposalDownload=function(id){
    	location.href="proposalDownload.do?id="+id;
    }
    

    $scope.loadData();
    
})
